package com.xhxg.service.impl;

import com.xhxg.dao.CustomerDao;
import com.xhxg.pojo.Customer;
import com.xhxg.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

//spring service接口实现
@Service("customerService")
public class CustomerServiceImpl implements CustomerService {

    @Autowired
    private CustomerDao customerDao;

    @Override
    public Customer selectCustomer(int id) {
        return customerDao.selectCustomer(id);
    }

    @Override
    public int insertCustomer(Customer customer) {
        return customerDao.insertCustomer(customer);
    }

    public int updateCustomerXML(Customer customer) {
        return customerDao.updateCustomerXML(customer);
    }

    @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT, readOnly = false)
    @Override
    public int updateCustomerAnnon(Customer customer) {
        int num = customerDao.updateCustomerAnnon(customer);
        // 模拟系统运行时的突发性问题

        return num;
    }

    @Override
    public int deleteCustomer(int id) {
        return customerDao.deleteCustomer(id);
    }

}
